/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Telas;

import RelatoriosCarregar.AgendamentoCarregar;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;

/**
 *
 * @author Marcos
 */
public class Jp_RelatorioAgendamento extends javax.swing.JPanel {

    public static Date dt_ini, dt_fim;
    //public static List<String> listaOm;

    /**
     * Creates new form Jp_RelatorioAgendamento
     */
    public Jp_RelatorioAgendamento() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelDtAtendimento = new javax.swing.JLabel();
        jFormattedTextFieldDtIni = new javax.swing.JFormattedTextField();
        jFormattedTextFieldDtFim = new javax.swing.JFormattedTextField();
        jLabelAte = new javax.swing.JLabel();
        jButtonExecutar = new javax.swing.JButton();
        jLabelCamposObrigatorios = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabelDtAtendimento.setText("*Atendimento de:");

        try {
            jFormattedTextFieldDtIni.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            jFormattedTextFieldDtFim.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabelAte.setText("até");

        jButtonExecutar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Executar.png"))); // NOI18N
        jButtonExecutar.setText("Executar");
        jButtonExecutar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExecutarActionPerformed(evt);
            }
        });

        jLabelCamposObrigatorios.setFont(new java.awt.Font("sansserif", 1, 12)); // NOI18N
        jLabelCamposObrigatorios.setText("* Campos Obrigatórios a serem preechidos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelDtAtendimento)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldDtIni, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelAte)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldDtFim, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonExecutar)
                    .addComponent(jLabelCamposObrigatorios))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDtAtendimento)
                    .addComponent(jFormattedTextFieldDtIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelAte)
                    .addComponent(jFormattedTextFieldDtFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonExecutar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCamposObrigatorios)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonExecutarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExecutarActionPerformed
        /*
         if ("  /  /    ".equals(jFormattedTextFieldDtIni.getText()) || "  /  /    ".equals(jFormattedTextFieldDtFim.getText())) {
         JOptionPane.showMessageDialog(null, "Informe uma data inicial e uma data final para o ralatório!", "Atenção", JOptionPane.WARNING_MESSAGE);
         jFormattedTextFieldDtIni.grabFocus();
         } else {
         AgendamentoCarregar AC = new AgendamentoCarregar();
         try {
         AC.abrirRelatorioAgendamento();
         } catch (SQLException ex) {
         Logger.getLogger(Jp_RelatorioAgendamento.class.getName()).log(Level.SEVERE, null, ex);
         } catch (JRException ex) {
         Logger.getLogger(Jp_RelatorioAgendamento.class.getName()).log(Level.SEVERE, null, ex);
         }
         }
         */

        AgendamentoCarregar AC = new AgendamentoCarregar();
        try {
            AC.abrirRelatorioAgendamento();
        } catch (SQLException ex) {
            Logger.getLogger(Jp_RelatorioAgendamento.class.getName()).log(Level.SEVERE, null, ex);
        } catch (JRException ex) {
            Logger.getLogger(Jp_RelatorioAgendamento.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonExecutarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonExecutar;
    private javax.swing.JFormattedTextField jFormattedTextFieldDtFim;
    private javax.swing.JFormattedTextField jFormattedTextFieldDtIni;
    private javax.swing.JLabel jLabelAte;
    private javax.swing.JLabel jLabelCamposObrigatorios;
    private javax.swing.JLabel jLabelDtAtendimento;
    // End of variables declaration//GEN-END:variables
}
